package com.shuai.AI.ai_app.rag.other;

import jakarta.annotation.Resource;
import java.util.List;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.document.Document;
import org.springframework.ai.model.transformer.KeywordMetadataEnricher;
import org.springframework.stereotype.Component;

/** 基于 AI 的文档元信息增强器（为文档补充元信息） */
@Component
public class MyKeywordEnricher {

  @Resource private ChatModel dashscopeChatModel;

  public List<Document> enrichDocuments(List<Document> documents) {
    KeywordMetadataEnricher keywordMetadataEnricher =
        new KeywordMetadataEnricher(dashscopeChatModel, 5);
    return keywordMetadataEnricher.apply(documents);
  }
}
